package com.lenovo.lcdm.type.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lenovo.lcdm.common.enums.DeleteFlagEnum;
import com.lenovo.lcdm.type.entity.TypeDefinitionMaster;
import com.lenovo.lcdm.type.mapper.TypeDefinitionMasterMapper;
import com.lenovo.lcdm.type.service.TypeDefinitionMasterService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
* @author xujing30
* @description Service实现
* @createDate 2024-01-03
*/
@Service
public class TypeDefinitionMasterServiceImpl extends ServiceImpl<TypeDefinitionMasterMapper, TypeDefinitionMaster>
    implements TypeDefinitionMasterService{


    @Override
    public Map<Long,TypeDefinitionMaster> queryById(List<Long> ids) {
        Map<Long,TypeDefinitionMaster> map = new HashMap<>();
        LambdaQueryWrapper<TypeDefinitionMaster> typeDefinitionMasterQw = new LambdaQueryWrapper();
        typeDefinitionMasterQw.in(TypeDefinitionMaster::getId, ids).eq(TypeDefinitionMaster::getDeleted, DeleteFlagEnum.NO.getValue());
        List<TypeDefinitionMaster> list = this.list(typeDefinitionMasterQw);
        if(!CollectionUtils.isEmpty(list)){
            map = list.stream().collect(Collectors.toMap(TypeDefinitionMaster::getId, Function.identity()));
        }
        return map;
    }
}




